<?php

class ZFDulcet_View_Helper_Mainmenu extends Zend_View_Helper_Navigation_Menu {

	public function mainmenu(Zend_Navigation_Container $container = null) {
		return parent::menu($container);
	}

	public function htmlify(Zend_Navigation_Page $page) {
		// get label and title for translating
		$label = $page->getLabel();
		$title = $page->getTitle();

		// translate label and title?
		if ($this->getUseTranslator() && $t = $this->getTranslator()) {
			if (is_string($label) && !empty($label)) {
				$label = $t->translate($label);
			}
			if (is_string($title) && !empty($title)) {
				$title = $t->translate($title);
			}
		}
		
		// get attribs for element
		$attribs = array(
			'id' => $page->getId(),
			'title' => $title,
			'class' => $page->getClass()
		);
		
		$attribs['class'] .= ($attribs['class'] != '') ? ' ' . $attribs['id'] : $attribs['id'];
		if($attribs['title'] == '') {
			$attribs['title'] = $label;
		}

		// does page have a href?
		if ($href = $page->getHref()) {
			$element = 'a';
			$attribs['href'] = $href;
			$attribs['target'] = $page->getTarget();
			$attribs['accesskey'] = $page->getAccessKey();
		}
		else {
			$element = 'span';
		}

		return '<' . $element . $this->_htmlAttribs($attribs) . '>'
				. '<img src="/temas/mkadmin/images/spacer.png" alt="' . $label . '">' . $this->view->escape($label)
				. '</' . $element . '>';
	}

}